import unittest
import requests

version = 5

class TestLogin(unittest.TestCase):

    @unittest.skipIf(version<3,'当前测试用例，只有在3.0版本以上才会执行')
    def test_login_se(self):
        print('-----------------------1')
        url = 'http://127.0.0.1:9099/login'

        # 构造数据
        json_data = {
            "username":"admin",
            "password":"admin123"
        }
        # 发送接口请求
        response = requests.post(url=url,json=json_data)

        # 获取返回的json数据
        response_data = response.json()
        current_msg = response_data["errMsg"]

        # 断言
        self.assertEqual('success',current_msg)  #期望值 ，实际结果


    def test_login_success(self):
        print('---------------------------2')
        url = 'http://127.0.0.1:9099/login'

        # 构造数据
        json_data = {
            "username":"admin",
            "password":"admin123"
        }
        # 发送接口请求
        response = requests.post(url=url,json=json_data)

        # 获取返回的json数据
        response_data = response.json()
        current_msg = response_data["errMsg"]

        # 断言
        self.assertEqual('success',current_msg)  #期望值 ，实际结果




